package keter.util;

import keter.domain.Account;
import keter.domain.Role;

/**
 * 用户测试数据生成.
 * 
 * @author calvin
 */
public class AccountUtil {

	public static Account buildAdmin() {
		Account acc = new Account();
		acc.setName("admin");
		acc.setPassword("1");
		acc.setRepeatPassword("1");
//		acc.setSno("1");
		acc.getRoleList().add(AccountUtil.adminRole());
		acc.getRoleList().add(AccountUtil.teacherRole());
		acc.setRemark("系统管理员");
		return acc;
	}
	
	public static Account buildTeacherAccount(String name) {
		Account user = new Account();
		user.setName(name);
		user.setRemark("教师账户，系统创建");
		user.setPassword("1");
		user.setRepeatPassword("1");
		user.getRoleList().add(AccountUtil.teacherRole());
		return user;
	}

	public static Account buildStudentAccount(String name,String sno) {
		Account user = new Account();
		user.setName(name);
//		user.setSno(sno);
		user.setPassword("1");
		user.setRepeatPassword("1");
		user.getRoleList().add(AccountUtil.studentRole());
		user.setRemark("学生用户，由系统创建");
		return user;
	}
	
	public static Account randomAdminAccount() {
		Account user = randomAccount();
		Role adminRole = adminRole();
		user.getRoleList().add(adminRole);
		return user;
	}
	
	public static Account randomAccount() {
		Account user = buildTeacherAccount(KeterRandUtil.randomName("teacher-account"));
//		user.setSno(KeterRandUtil.randomName("1"));
		user.getRoleList().add(teacherRole());
		user.setRemark(KeterRandUtil.randomName("描述:"));
		return user;
	}

	public static Role adminRole() {
		Role role = new Role();
		role.setId(1L);
		role.setName("ADMIN");
		role.setLabel("管理员");
		return role;
	}
	
	public static Role teacherRole() {
		Role role = new Role();
		role.setId(2L);
		role.setName("TEACHER");
		role.setLabel("普通用户");
		return role;
	}
	public static Role studentRole() {
		Role role = new Role();
		role.setId(3L);
		role.setName("STUDENT");
		role.setLabel("普通用户");
		return role;
	}
}
